# 点赞模块
from model import db
import datetime
from sqlalchemy.dialects.mysql import LONGTEXT


class Like(db.Model):
    __tablename__ = "like"  # 映射的数据表，不写默认是类名
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    photo_id = db.Column(db.Integer, nullable=False)
    action = db.Column(db.String(64), nullable=False)
    user_id = db.Column(db.Integer, nullable=False)

    def keys(self):
        return ("photo_id", 'action')

    def __getitem__(self, item):
        return getattr(self, item)